package test3.main;

import java.awt.Font;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;

public class Login extends JFrame {
	JLabel id;
	JLabel password;
	JTextField idText;
	JPasswordField passwordText;
	JButton login;
	JButton cancel;
	JPanel loginPanel;	
	public Login(int x,int y,int width,int height) {	
		init();
		setLocation(x,y);
		setSize(width,height);
		setVisible(true);
		setDefaultCloseOperation(DISPOSE_ON_CLOSE);
		this.add(loginPanel);
		this.setResizable(false);
	}
	private void init() {
		loginPanel = new JPanel();
		loginPanel.setLayout(null);
		setTitle("Login");
		id = new JLabel("User ID:");
		password = new JLabel("Password:");
		idText = new JTextField(20);
		passwordText = new JPasswordField(20);
		login = new JButton("Login");
		cancel = new JButton("Cancel");
		JLabel title = new JLabel("Information Management System");
		loginPanel.add(title);
		title.setBounds(220, 80, 400, 30);
		title.setFont(new Font("黑体",Font.BOLD,22));
		loginPanel.add(id);
		id.setBounds(220,150,100,30);
		loginPanel.add(idText);
		idText.setBounds(300, 150, 250, 30);
		loginPanel.add(password);
		password.setBounds(220,220,100,30);
		loginPanel.add(passwordText);
		passwordText.setBounds(300, 220, 250, 30);
		loginPanel.add(login);
		login.setBounds(250, 300, 100, 30);
		loginPanel.add(cancel);
		cancel.setBounds(420, 300, 100, 30);
		
		login.addActionListener(new LoginAction(this));
		cancel.addActionListener(new LoginAction(this));
	}
}
